package com.lhf.azkaban.springbatch.example.job.listener;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.listener.JobExecutionListenerSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author:95780
 * @Date: 14:22 2019/11/21
 * @Description: 对JOB的监听实现类
 */
@Component
public class MyJobListener extends JobExecutionListenerSupport {
    private static final Logger logger = LogManager.getLogger(MyJobListener.class);

//    @Autowired
//    private MapExecutionTracker mapExecutionTracker;

    //在job工作之前；
    @Override
    public void beforeJob(JobExecution jobExecution) {
        /*获取job名称*/
        logger.info(" MyJobListener job[{}] start run.", jobExecution.getJobInstance().getJobName());
//        mapExecutionTracker.saveJobExecution(jobExecution);
    }

    @Override
    public void afterJob(JobExecution jobExecution) {
        logger.info(" MyJobListener job[{}] end run.", jobExecution.getJobInstance().getJobName());

//        mapExecutionTracker.saveJobExecution(jobExecution);
    }
}
